package mqtt;


import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.Core.Types.OperateResultExTwo;
import HslCommunication.MQTT.MqttConnectionOptions;
import HslCommunication.MQTT.MqttSyncClient;
import HslCommunication.Utilities;

import java.text.SimpleDateFormat;
import java.util.HashMap;

/**
 * Copyright (C) 广州中和互联网技术有限公司
 *
 * @author 范家微 fanjiawei@borche.cn
 * @date :2020/12/26 11:42
 */
public class Test {
	public static void main(String[] args) {

		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		MqttSyncClient mqttSync = new MqttSyncClient("127.0.0.1", 1883);
		mqttSync.SetPersistentConnection();

		//只能发布不能发布
		HashMap<String, Object> map = new HashMap<>();
		map.put("name","张三");
		map.put("pwd","123456");
		String string = map.toString();
		OperateResultExTwo<String, byte[]> a = mqttSync.Read("D", Utilities.getBytes(string, "UTF-8"));

		System.out.println(Utilities.getString(a.Content2, "UTF-8"));
		OperateResultExOne<String[]> one = mqttSync.ReadRetainTopics();
		for (String s : one.Content) {
			System.out.println(s);
		}

	}
}
